# TODO: Add comment
# 
# Author: guochun
###############################################################################


selectnu=function(modelingObject,rmax=40){
	
	#fittedModel=inhomK(modelingObject,r=seq(0,rmax,length.out=120))
	fittedModel=inhompcf(modelingObject,maxt=100,bw=10)
	#here sigma2 represents sigma^2
	#if the nu is not given, do selection of the best nu
	if(modelingObject@nu==0){
		#PlogG=best.matern.estK(attr(fittedModel,"K"), c(sigma2=3, alpha=10),
		#		rmax=rmax,rmin=0,nu=c(Inf,0.25,0.5,1,4))
		PlogG=best.matern.estpcf(attr(fittedModel,"K"), c(sigma2=3, alpha=10),
				rmax=rmax,rmin=10,nu=c(Inf,0.25,0.5,1,4))
		nu=attr(PlogG,"nu")
	}else{
		return(modelingObject@nu)
	}
}
